package com.lqian.map;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class NoSafe4HashMap {

        public static void main(String[] args) {
            //演示HashMap
            Map<String, String> map = new HashMap<>(); //ConcurrentHashMap替换解决
            for (int i = 0; i < 30; i++) {
                String key = String.valueOf(i);
                new Thread(() -> {
                    //向集合添加内容
                    map.put(key, UUID.randomUUID().toString().substring(0, 8));
                    //从集合中获取内容
                    System.out.println(map);
                }, "").start();

            }
        }

}
